import 'dart:convert';
import 'package:yp/Xwidgets/pay_bottom_sheet.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

// import 'package:timelines/timelines.dart';
import 'package:flutter/services.dart';

// import 'package:yp/views/order_detial/widgets/text_input.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

// import 'package:yp/views/order_detial/widgets/item_widgets.dart';
import 'package:intl/intl.dart';
import 'package:sp_util/sp_util.dart';
import 'package:yp/Xwidgets/button_widget.dart';
import 'package:yp/Xwidgets/line.dart';
import 'package:yp/config/config.dart';
import 'package:yp/config/rules.dart';
import 'package:yp/config/style.dart';
import 'package:yp/helper.dart';
import 'package:yp/pages/order/order/order_view.dart';
import 'package:yp/pages/order_detial/widgets/item_pre_widgets.dart';
import 'package:yp/pages/order_detial/widgets/text_input.dart';
import 'package:yp/router.dart';
import 'package:yp/services/api.dart';

import 'logic.dart';
import 'state.dart';
import 'widgets/item_widgets.dart';

class OrderDetialPage extends StatefulWidget {
  @override
  _OrderDetialPageState createState() => _OrderDetialPageState();
}

class _OrderDetialPageState extends State<OrderDetialPage> {
  final OrderDetialLogic logic = Get.put(OrderDetialLogic());

  final OrderDetialState state = Get.find<OrderDetialLogic>().state;

  Widget googsPrice(
    String title,
    money, {
    bool isDiscount = true,
    bool hidePreSymbol = false,
  }) {
    return Padding(
      padding: const EdgeInsets.only(left: 10, top: 5, right: 10),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(title, style: TextStyle(color: Colors.grey)),
          Text(
              '${hidePreSymbol == true ? "" : isDiscount ? "-" : "+"}￥$money',
              style: TextStyle(color: Colors.grey))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        backgroundColor: Config.mainColor,
        brightness: Brightness.light,
        iconTheme: IconThemeData(color: Colors.white),
        title: Text(
          "订单详情",
          style: TextStyle(color: Colors.white, fontSize: 32.sp),
        ),
        centerTitle: true,
        elevation: 0,
      ),
      body: GetBuilder<OrderDetialLogic>(
        builder: (logic) {
          return state.detail == null
              ? Container()
              : Column(
                  children: [
                    Expanded(
                      child:
                          ListView(shrinkWrap: true, primary: true, children: [
                        Column(
                          children: [
                            Container(
                              width: 750.w,
                              decoration: BoxDecoration(
                                color: Color(0xffF8EEE9),
                              ),
                              padding: EdgeInsets.only(top: 40.w, bottom: 28.w),
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Container(
                                    child: RichText(
                                      text: TextSpan(
                                        style: TextStyle(
                                          color: Config.mainColor,
                                          fontSize: 32.w,
                                        ),
                                        children: [
                                          WidgetSpan(
                                            child: Image.asset(
                                              "assets/images/orderdetial.png",
                                              width: 42.w,
                                              height: 42.w,
                                            ),
                                            alignment:
                                                PlaceholderAlignment.baseline,
                                            baseline: TextBaseline.ideographic,
                                          ),
                                          WidgetSpan(
                                            child: SizedBox(
                                              width: 5.w,
                                            ),
                                          ),
                                          TextSpan(
                                            text:
                                                '${state.detail['operate_status_name']}',
                                            style: TextStyle(
                                              color: Config.mainColor,
                                              fontSize: 32.w,
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                  state.detail['status_num_id'] == 1 &&
                                          state.timerValue != ""
                                      ? Container(
                                          height: 30.w,
                                          child: Text(
                                            "付款倒计时：${state.timerValue}",
                                            style: TextStyle(
                                                fontSize: 24.sp,
                                                color: Config.mainColor),
                                          ),
                                        )
                                      : Container(height: 30.w)
                                ],
                              ),
                            ),
                            Container(
                              width: 750.w,
                              color: Colors.white,
                              padding: EdgeInsets.symmetric(
                                  horizontal: 40.w, vertical: 30.w),
                              child: Column(
                                children: [
                                  /// 买家地址
                                  Row(
                                    children: [
                                      ClipRRect(
                                        borderRadius: BorderRadius.all(
                                            Radius.circular(64.w)),
                                        child: Container(
                                          width: 64.w,
                                          height: 64.w,
                                          decoration: BoxDecoration(
                                            color: Config.mainColor,
                                          ),
                                          child: Center(
                                            child: Icon(
                                              Icons.location_on,
                                              color: Colors.white,
                                              size: 15,
                                            ),
                                          ),
                                        ),
                                      ),
                                      SizedBox(width: 22.w),
                                      Expanded(
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: [
                                            Text(
                                              "买家：${state.detail['user_name']}",
                                              style: TextStyle(
                                                fontSize: 28.sp,
                                                color: Colors.black,
                                              ),
                                            ),

                                            /// 自提
                                            if (state.switchValue)
                                              Text(
                                                "${state.detail['consumer_telephone'] ?? ''}",
                                                style: TextStyle(
                                                  fontSize: 28.sp,
                                                  color: Colors.black,
                                                ),
                                              ),

                                            /// 自提
                                            if (!state.switchValue)
                                              Text(
                                                "${state.detail['consumer_prv_name']} ${state.detail['consumer_city_name']} ${state.detail['consumer_city_area_name']}  ${state.detail['consumer_adr']}",
                                                style: TextStyle(
                                                  fontSize: 26.sp,
                                                  color: Color(0xff666666),
                                                ),
                                                maxLines: 2,
                                                overflow: TextOverflow.ellipsis,
                                              ),
                                            SizedBox(
                                              height: 10.w,
                                            ),
                                            state.switchValue
                                                ? Text(
                                                    "您已经选择自提，商品到达自提点后凭借提货码提货",
                                                    style: TextStyle(
                                                      fontSize: 22.sp,
                                                      color: Color(0xffDB2132),
                                                    ),
                                                  )
                                                : Container(),
                                          ],
                                        ),
                                      ),
                                      state.detail['status_num_id'] <= 3
                                          ? !state.switchValue
                                              ? Visibility(
                                                  visible: state.detail[
                                                                  'user_num_id']
                                                              .toString() ==
                                                          SpUtil.getInt(
                                                                  'empeNumId')
                                                              .toString()
                                                      ? true
                                                      : false,
                                                  child: GestureDetector(
                                                    onTap: () {
                                                      //toast('message123123123');
                                                      Get.toNamed(
                                                          RouteConfig
                                                              .orderModifyAddress,
                                                          arguments: {
                                                            'orderNum': state
                                                                    .detail[
                                                                'tml_num_id'], // 订单ID
                                                            'userName': state
                                                                    .detail[
                                                                'user_name'], // 买家姓名
                                                            'phone': state
                                                                    .detail[
                                                                'consumer_telephone'], //买家电话
                                                            'region': logic
                                                                .fmtRegion(), // 区域文本
                                                            'addrDetail': state
                                                                    .detail[
                                                                'consumer_adr'], // 详细地址
                                                          }).then((value) {
                                                        logic.onReady();
                                                      });
                                                    },
                                                    child: state.ordertype == 1
                                                        ? Center(
                                                            child: Text(
                                                              "修改",
                                                              style: TextStyle(
                                                                color: Config
                                                                    .mainColor,
                                                                fontSize: 24.sp,
                                                              ),
                                                            ),
                                                          )
                                                        : Center(),
                                                  ),
                                                )
                                              : Container()
                                          : Container(),
                                    ],
                                  ),
                                  Divider(
                                    color: Color(0xfff5f5f5),
                                  ),
                                  state.detail['status_num_id'] <= 3
                                      ? Row(
                                          children: [
                                            ClipRRect(
                                              borderRadius: BorderRadius.all(
                                                  Radius.circular(64.w)),
                                              child: Container(
                                                width: 64.w,
                                                height: 64.w,
                                                decoration: BoxDecoration(
                                                  color: Colors.white,
                                                ),
                                                child: Center(),
                                              ),
                                            ),
                                            SizedBox(width: 22.w),
                                            Expanded(
                                              child: Column(
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                children: [
                                                  // Visibility(
                                                  //   visible: state.detail['adr_type'] == 1&&(state.detail['operate_status_num_id'] == 90070||state.detail['operate_status_num_id'] == 90065||state.detail['operate_status_num_id'] == 90120)?true:false,
                                                  //   child: Row(
                                                  //     children: [
                                                  //       Text(
                                                  //         "选择自提点提货",
                                                  //         style: TextStyle(
                                                  //           fontSize: 24.sp,
                                                  //           color: Color(0xff666666),
                                                  //         ),
                                                  //       ),
                                                  //       Transform.scale(
                                                  //         scale: 0.6,
                                                  //         child: CupertinoSwitch(
                                                  //           value:state.switchValue,
                                                  //           activeColor:Color(0xffEA5504),
                                                  //           trackColor:Color(0xffEBEBEB),
                                                  //           // 点击或者拖拽事件
                                                  //           onChanged: (value) {
                                                  //             if (state.detail['inv_from_type'] !=3) {
                                                  //               logic.switchType(value);
                                                  //             }
                                                  //           },
                                                  //         ),
                                                  //       )
                                                  //     ],
                                                  //   ),
                                                  // ),
                                                  if (state.switchValue &&
                                                      state.selected != -1)
                                                    Text(
                                                      "${state.detail['adr_name'] ?? ''}",
                                                      style: TextStyle(
                                                        fontSize: 28.sp,
                                                        color: Colors.black,
                                                      ),
                                                    ),
                                                  if (state.switchValue &&
                                                      state.selected == -1)
                                                    Row(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .spaceBetween,
                                                      children: [
                                                        Container(
                                                          width: 400.w,
                                                          child: Text(
                                                            "请先选择自提点",
                                                            style: TextStyle(
                                                              fontSize: 28.sp,
                                                              color: Config
                                                                  .mainColor,
                                                            ),
                                                          ),
                                                        ),
                                                        GestureDetector(
                                                          onTap: () {
                                                            showDialog(
                                                              context: context,
                                                              builder:
                                                                  (context) {
                                                                return _selectProduct(
                                                                    context);
                                                              },
                                                            );
                                                          },
                                                          child: Container(
                                                            width: 120.w,
                                                            height: 40.w,
                                                            decoration:
                                                                BoxDecoration(
                                                              borderRadius: BorderRadius
                                                                  .all(Radius
                                                                      .circular(
                                                                          100)),
                                                              border:
                                                                  Border.all(
                                                                color: Color(
                                                                    0xffe1e1e1),
                                                              ),
                                                            ),
                                                            child: Center(
                                                              child: Text(
                                                                "选择",
                                                                style:
                                                                    TextStyle(
                                                                  fontSize:
                                                                      24.sp,
                                                                  color: Color(
                                                                      0xff666666),
                                                                ),
                                                              ),
                                                            ),
                                                          ),
                                                        ),
                                                      ],
                                                    ),
                                                  if (state.switchValue &&
                                                      state.selected != -1)
                                                    Row(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .spaceBetween,
                                                      children: [
                                                        Container(
                                                          width: 490.w,
                                                          child: Text(
                                                            state.dianAdr ?? "",
                                                            style: TextStyle(
                                                              fontSize: 26.sp,
                                                              color: Color(
                                                                  0xff333333),
                                                            ),
                                                          ),
                                                        ),
                                                        GestureDetector(
                                                          onTap: () {
                                                            showDialog(
                                                              context: context,
                                                              builder:
                                                                  (context) {
                                                                return _selectProduct(
                                                                    context);
                                                              },
                                                            );
                                                          },
                                                          child: Container(
                                                            width: 90.w,
                                                            height: 40.w,
                                                            decoration:
                                                                BoxDecoration(
                                                              borderRadius: BorderRadius
                                                                  .all(Radius
                                                                      .circular(
                                                                          100)),
                                                              border:
                                                                  Border.all(
                                                                color: Color(
                                                                    0xffe1e1e1),
                                                              ),
                                                            ),
                                                            child: Center(
                                                              child: Text(
                                                                "修改",
                                                                style:
                                                                    TextStyle(
                                                                  fontSize:
                                                                      24.sp,
                                                                  color: Color(
                                                                      0xff666666),
                                                                ),
                                                              ),
                                                            ),
                                                          ),
                                                        ),
                                                      ],
                                                    )
                                                ],
                                              ),
                                            ),
                                          ],
                                        )
                                      : Container(),
                                ],
                              ),
                            ),
                            Container(
                              height: 24.w,
                              color: Color(0xffF5F5F5),
                            ),
                            //商品部分
                            Container(
                              padding: EdgeInsets.symmetric(
                                  horizontal: 20.w, vertical: 16.w),
                              child: Column(
                                children: [
                                  Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: [
                                      Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.center,
                                        children: [
                                          Image.asset(
                                            "assets/images/store.png",
                                            width: 30.w,
                                            height: 30.w,
                                          ),
                                          SizedBox(
                                            width: 5.w,
                                          ),
                                          Text(
                                            "${state.detail['ec_shop_name']}",
                                            style: TextStyle(
                                              fontSize: 28.sp,
                                              color: Color(0xff222222),
                                            ),
                                          ),
                                        ],
                                      ),
                                      GestureDetector(
                                        onTap: () {
                                          var otherParams = {
                                            "productInfo": {},
                                            // "peerId": "10052439",
                                            "nickName": "${SpUtil.getString('empeName')}",
                                          };
                                          var shopinfo = state.ec_shop_num_id;
                                          var clientId = '${SpUtil.getInt('empeNumId')}';

                                          otherParams["productInfo"] = {
                                            "visible": true,
                                            "actionText": "发送",
                                            "actionTextColor": "#fff",
                                            "title": state.otherParams['title'],
                                            "sub_title":
                                                state.otherParams['sub_title'],
                                            "other_title_one": state
                                                .otherParams['other_title_one'],
                                            // "other_title_two":"吊灯极品装饰",
                                            // "other_title_three":"吊灯极品装饰",
                                            "img": state.otherParams['img'],
                                            "price": state.otherParams['price'],
                                            "attr_one": {
                                              "color": "#000000",
                                              "content": "X1"
                                            },
                                            "attr_two": {
                                              "color": "#000000",
                                              "content": "已发货"
                                            },
                                            "time": "agent",
                                            "showCardInfoMsg": 1
                                          };

                                          var kefubaseUrl =
                                              'https://7moor.zrhsh.com/wapchat.html?fromUrl=&urlTitle=&language=ZHCN';
                                          kefubaseUrl = kefubaseUrl +
                                              '&accessId=' +
                                              state.accessId +
                                              '&otherParams=' +
                                              jsonEncode(otherParams) +
                                              '&clientId=' +
                                              clientId;

                                          Get.toNamed(RouteConfig.webview,
                                              arguments: {
                                                "url": kefubaseUrl,
                                              });
                                        },
                                        child: Image.asset(
                                          "assets/images/kefu1.png",
                                          width: 60.w,
                                        ),
                                      )
                                    ],
                                  ),
                                  Divider(
                                    color: Color(0xffcccccc),
                                  )
                                ],
                              ),
                            ),
                            Padding(
                              padding: EdgeInsets.symmetric(horizontal: 20.w),
                              child: Column(
                                children: [
                                  ListView.separated(
                                    shrinkWrap: true,
                                    itemCount: state
                                        .detail['distribution_order_item']
                                        .length,
                                    separatorBuilder: (ctx, i) {
                                      return Divider(color: Color(0xffcccccc));
                                    },
                                    physics: NeverScrollableScrollPhysics(),
                                    itemBuilder: (ctx, i) {
                                      var data = state
                                          .detail['distribution_order_item'][i];
                                      return state.detail['is_pre_customer'] ==
                                              1
                                          ? ItemPreWidget(
                                              orderData: state.detail,
                                              data: data,
                                              serviceFlag: state
                                                  .detail['af_service_flag'],
                                              logic: logic,
                                            )
                                          : ItemWidget(
                                              orderData: state.detail,
                                              data: data,
                                              serviceFlag: state
                                                  .detail['af_service_flag'],
                                              logic: logic,
                                            );
                                    },
                                  ),
                                  Divider(color: Color(0xffcccccc)),
                                  if (state.detail != null &&
                                      (state.detail['operate_status_name'] ==
                                              "待支付尾款" ||
                                          state.detail['operate_status_name'] ==
                                              "待发货" ||
                                          state.detail['operate_status_name'] ==
                                              "已发货" ||
                                          state.detail['operate_status_name'] ==
                                              "已付款" ||
                                          state.detail['operate_status_name'] ==
                                              "已收货" ||
                                          state.detail['operate_status_name'] ==
                                              "已拣货") &&
                                      state.ordertype == 1)
                                    state.detail['is_pre_customer'] == 1
                                        ? GestureDetector(
                                            onTap: () {
                                              Get.toNamed(
                                                  RouteConfig.aftersaleApply,
                                                  arguments: {
                                                    'type': 1,
                                                    'isPre': state.detail[
                                                        'is_pre_customer'],
                                                    'id': logic.state.id,
                                                    'data': state.detail[
                                                        "distribution_order_item"]
                                                  }).then((value) {
                                                logic.onReady();
                                                logic.update();
                                              });
                                            },

                                            ///全款支付隐藏全部退款按钮
                                            child: Visibility(
                                              visible: state.detail["amount"]
                                                          ["deposit_amount"] !=
                                                      0.0 &&
                                                  state.detail["amount"]
                                                          ["need_pay_amount"] !=
                                                      0.0,
                                              child: Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment.end,
                                                children: [
                                                  Container(
                                                    width: 160.w,
                                                    height: 60.w,
                                                    decoration: BoxDecoration(
                                                      borderRadius:
                                                          BorderRadius.all(
                                                        Radius.circular(80),
                                                      ),
                                                      border: Border.all(
                                                        color:
                                                            Color(0xffCCCCCC),
                                                      ),
                                                    ),
                                                    child: Center(
                                                      child: Text(
                                                        "申请退款",
                                                        style: TextStyle(
                                                          fontSize: 24.w,
                                                          color:
                                                              Color(0xff222222),
                                                        ),
                                                      ),
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ),
                                          )
                                        : Container(),
                                ],
                              ),
                            ),
                            Container(
                              height: 24.w,
                              color: Color(0xffF5F5F5),
                            ),
                            state.detail['so_sign'] == 40
                                ? // 定金预售
                                Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      // 发货日期
                                      state.detail['so_sign'] == 40
                                          ? Padding(
                                              padding: const EdgeInsets.all(10),
                                              child: Row(
                                                children: [
                                                  Text(
                                                    "发货日期: ",
                                                    style: TextStyle(
                                                      color: Color(0xff666666),
                                                      fontSize: 26.sp,
                                                    ),
                                                  ),
                                                  Expanded(
                                                    child: Text(
                                                      " ${state.detailDeliveryTime}",
                                                      maxLines: 1,
                                                      overflow:
                                                          TextOverflow.ellipsis,
                                                      style: TextStyle(
                                                        fontSize: 24.sp,
                                                        color:
                                                            Color(0xff000000),
                                                      ),
                                                    ),
                                                  )
                                                ],
                                              ),
                                            )
                                          : state.detail[
                                                      'balance_payment_dtme'] !=
                                                  null
                                              ? TextInputWidget(
                                                  title: "发货日期",
                                                  suffixWidget: GestureDetector(
                                                    child: Row(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment.end,
                                                      children: [
                                                        Text(
                                                          "${state.detail['balance_payment_dtme']}",
                                                          style: TextStyle(
                                                            fontSize: 28.sp,
                                                            color: Color(
                                                                0xff000000),
                                                          ),
                                                        )
                                                      ],
                                                    ),
                                                  ),
                                                )
                                              : SizedBox(),
                                      // 定金预售付尾款时间
                                      state.detail['balance_start_dtme'] != null
                                          ? TextInputWidget(
                                              title: "付尾款日期",
                                              suffixWidget: GestureDetector(
                                                onTap: () {
                                                  print(
                                                      'user_num_id:${state.detail['user_num_id']}');
                                                },
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment.end,
                                                  children: [
                                                    Text(
                                                      '${state.detail['balance_start_dtme']}',
                                                      style: TextStyle(
                                                          fontSize: 28.sp),
                                                    )
                                                  ],
                                                ),
                                              ),
                                            )
                                          : SizedBox(),
                                    ],
                                  )
                                : SizedBox(),
                            state.detail['so_sign'] == 19
                                ? TextInputWidget(
                                    title: "预付差额时间",
                                    suffixWidget: GestureDetector(
                                      child: Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.end,
                                        children: [
                                          Text(
                                            "${state.balancePaymentDtme}",
                                            style: TextStyle(
                                              fontSize: 28.sp,
                                              color: Color(0xff000000),
                                            ),
                                          )
                                        ],
                                      ),
                                    ),
                                  )
                                : SizedBox(),
                            state.detail['so_sign'] == 14 &&
                                    state.tml_type == '预约发货'
                                ? Column(
                                    children: [
                                      TextInputWidget(
                                        title: "配送类型",
                                        suffixWidget: GestureDetector(
                                          onTap: () {
                                            // print(
                                            //     'user_num_id:${state.detail['user_num_id']}');
                                          },
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.end,
                                            children: [
                                              Text(
                                                '预约发货',
                                                style:
                                                    TextStyle(fontSize: 28.sp),
                                              )
                                            ],
                                          ),
                                        ),
                                      ),
                                      // 发货日期
                                      state.tml_type == '预约发货'
                                          ? TextInputWidget(
                                              title: "预约发货时间",
                                              suffixWidget: GestureDetector(
                                                onTap: () {
                                                  print('时间选着');
                                                  print(state
                                                      .detail['status_num_id']);
                                                  if (state.detail[
                                                          'status_num_id'] <=
                                                      2) {
                                                    DatePicker.showDatePicker(
                                                        context,
                                                        showTitleActions: true,
                                                        minTime: DateTime(
                                                            2010, 1, 1),
                                                        maxTime: DateTime(
                                                            2022, 12, 31),
                                                        onConfirm: (date) {
                                                      logic.selectDate(date);
                                                    },
                                                        currentTime:
                                                            DateTime.now(),
                                                        locale: LocaleType.zh);
                                                  }
                                                },
                                                child: Row(
                                                  mainAxisAlignment:
                                                      MainAxisAlignment.end,
                                                  children: [
                                                    Text(
                                                      "${DateFormat("yyyy-MM-dd").format(state.dateTime)}",
                                                      style: TextStyle(
                                                        fontSize: 28.sp,
                                                        color:
                                                            Color(0xff000000),
                                                      ),
                                                    ),
                                                    Icon(
                                                      Icons
                                                          .arrow_forward_ios_rounded,
                                                      color: Color(0xffcccccc),
                                                      size: 14,
                                                    )
                                                  ],
                                                ),
                                              ),
                                            )
                                          : Container(),
                                    ],
                                  )
                                : state.detail['so_sign'] != 40 &&
                                        state.detail['so_sign'] != 19
                                    ? Column(
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          // 配送类型
                                          TextInputWidget(
                                            title: "配送类型",
                                            suffixWidget: GestureDetector(
                                              onTap: () {
                                                print(
                                                    'user_num_id:${state.detail['user_num_id']}');
                                                print(
                                                    'empeNumId:${SpUtil.getInt('empeNumId')}');
                                                print(
                                                    'inv_from_type:${state.detail['inv_from_type']}');
                                                if (state.ordertype == 1 &&
                                                    state.detail[
                                                            'status_num_id'] <=
                                                        3 &&
                                                    state.detail[
                                                            'inv_from_type'] !=
                                                        3 &&
                                                    state.detail['user_num_id']
                                                            .toString() ==
                                                        SpUtil.getInt(
                                                                'empeNumId')
                                                            .toString()) {
                                                  _showCupertinoActionSheet1(
                                                      context);
                                                } else {
                                                  toast('分享订单无法改变配送类型');
                                                }
                                              },
                                              child: Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment.end,
                                                children: [
                                                  Text(
                                                    state.tml_type,
                                                    style: TextStyle(
                                                      fontSize: 28.sp,
                                                      color: state.tml_type ==
                                                              '请选择'
                                                          ? Color(0xffcccccc)
                                                          : Color(0xff000000),
                                                    ),
                                                  ),
                                                  Icon(
                                                    Icons
                                                        .arrow_forward_ios_rounded,
                                                    color: Color(0xffcccccc),
                                                    size: 14,
                                                  )
                                                ],
                                              ),
                                            ),
                                          ),
                                          // 发货日期
                                          state.tml_type == '预约发货'
                                              ? TextInputWidget(
                                                  title: "预约发货时间",
                                                  suffixWidget: GestureDetector(
                                                    onTap: () {
                                                      print('时间选着');
                                                      print(state.detail[
                                                          'status_num_id']);
                                                      if (state.detail[
                                                              'status_num_id'] <=
                                                          2) {
                                                        DatePicker
                                                            .showDatePicker(
                                                                context,
                                                                showTitleActions:
                                                                    true,
                                                                minTime:
                                                                    DateTime(
                                                                        2010,
                                                                        1,
                                                                        1),
                                                                maxTime:
                                                                    DateTime(
                                                                        2022,
                                                                        12,
                                                                        31),
                                                                onConfirm:
                                                                    (date) {
                                                          logic
                                                              .selectDate(date);
                                                        },
                                                                currentTime:
                                                                    DateTime
                                                                        .now(),
                                                                locale:
                                                                    LocaleType
                                                                        .zh);
                                                      }
                                                    },
                                                    child: Row(
                                                      mainAxisAlignment:
                                                          MainAxisAlignment.end,
                                                      children: [
                                                        Text(
                                                          "${DateFormat("yyyy-MM-dd").format(state.dateTime)}",
                                                          style: TextStyle(
                                                            fontSize: 28.sp,
                                                            color: Color(
                                                                0xff000000),
                                                          ),
                                                        ),
                                                        Icon(
                                                          Icons
                                                              .arrow_forward_ios_rounded,
                                                          color:
                                                              Color(0xffcccccc),
                                                          size: 14,
                                                        )
                                                      ],
                                                    ),
                                                  ),
                                                )
                                              : Container(),
                                        ],
                                      )
                                    : SizedBox(),
                            Container(
                              height: 24.w,
                              color: Color(0xffF5F5F5),
                            ),
                            Container(
                              color: Color(0xffFFFFFF),
                              padding: EdgeInsets.symmetric(
                                  horizontal: 20.w, vertical: 30.w),
                              child: Column(
                                children: [
                                  Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: [
                                      Row(
                                        children: [
                                          Text(
                                            "订单编号：",
                                            style: TextStyle(
                                              fontSize: 26.sp,
                                              color: Color(0xff666666),
                                            ),
                                          ),
                                          Text(
                                            "${state.detail['tml_num_id']}",
                                            style: TextStyle(
                                              fontSize: 26.sp,
                                              color: Color(0xff222222),
                                            ),
                                          ),
                                        ],
                                      ),
                                      GestureDetector(
                                        onTap: () {
                                          ClipboardData data =
                                              new ClipboardData(
                                                  text: state
                                                      .detail['tml_num_id']);
                                          Clipboard.setData(data);
                                          toast("复制成功");
                                        },
                                        child: Container(
                                          width: 90.w,
                                          height: 40.w,
                                          decoration: BoxDecoration(
                                            borderRadius: BorderRadius.all(
                                                Radius.circular(100)),
                                            border: Border.all(
                                              color: Color(0xffe1e1e1),
                                            ),
                                          ),
                                          child: Center(
                                            child: Text(
                                              "复制",
                                              style: TextStyle(
                                                  fontSize: 24.sp,
                                                  color: Color(0xff666666)),
                                            ),
                                          ),
                                        ),
                                      )
                                    ],
                                  ),
                                  SizedBox(
                                    height: 20.w,
                                  ),
                                  Row(
                                    children: [
                                      Text(
                                        "下单时间：",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff666666),
                                        ),
                                      ),
                                      Text(
                                        "${state.detail['create_dtme']}",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff222222),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    children: [
                                      Text(
                                        "支付方式：",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff666666),
                                        ),
                                      ),
                                      Text(
                                        "${state.payMethods}",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff222222),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    children: [
                                      Text(
                                        "如遇缺货：",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff666666),
                                        ),
                                      ),
                                      Text(
                                        "${state.detail['remark'] != null ? state.detail['remark'] : ''}",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff222222),
                                        ),
                                      ),
                                    ],
                                  ),
                                  Row(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      Text(
                                        "订单备注：",
                                        style: TextStyle(
                                          fontSize: 26.sp,
                                          color: Color(0xff666666),
                                        ),
                                      ),
                                      Expanded(
                                        child: Text(
                                          "${state.detail['buyer_memo'] != null ? state.detail['buyer_memo'] : ''}",
                                          maxLines: 100,
                                          style: TextStyle(
                                            fontSize: 26.sp,
                                            color: Color(0xff222222),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),

                                  SizedBox(
                                    height: 20.w,
                                  ),
                                  // Row(
                                  //   children: [
                                  //     Text(
                                  //       "线索编号：",
                                  //       style: TextStyle(
                                  //         fontSize: 26.sp,
                                  //         color: Color(0xff666666),
                                  //       ),
                                  //     ),
                                  //     Text(
                                  //       "${state.detail['clue_num_id'] ?? '无'}",
                                  //       style: TextStyle(
                                  //         fontSize: 26.sp,
                                  //         color: Color(0xff222222),
                                  //       ),
                                  //     ),
                                  //   ],
                                  // ),
                                  // SizedBox(
                                  //   height: 20.w,
                                  // ),
                                  // Row(
                                  //   children: [
                                  //     Text(
                                  //       "商机品类：",
                                  //       style: TextStyle(
                                  //         fontSize: 26.sp,
                                  //         color: Color(0xff666666),
                                  //       ),
                                  //     ),
                                  //     Text(
                                  //       "灶具、热水器",
                                  //       style: TextStyle(
                                  //         fontSize: 26.sp,
                                  //         color: Color(0xff222222),
                                  //       ),
                                  //     ),
                                  //   ],
                                  // ),
                                ],
                              ),
                            ),
                            Container(
                              height: 20.w,
                              color: Color(0xffF5F5F5),
                            ),
                            Container(
                              color: Color(0xffFFFFFF),
                              child: Column(
                                children: [
                                  Padding(
                                    padding: const EdgeInsets.only(
                                        left: 10, top: 5, right: 10),
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text('商品金额',
                                            style:
                                                TextStyle(color: Colors.grey)),
                                        Text(
                                            '￥${state.detail['amount']['goods_amount']}',
                                            style:
                                                TextStyle(color: Colors.grey))
                                      ],
                                    ),
                                  ),
                                  //if (state.detail['amount']['card_point'] > 0)
                                  Padding(
                                    padding: const EdgeInsets.only(
                                        left: 10, top: 5, right: 10),
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text('优惠券抵扣',
                                            style:
                                                TextStyle(color: Colors.grey)),
                                        Text(
                                            '-￥${state.detail['amount']['card_point']}',
                                            style:
                                                TextStyle(color: Colors.grey))
                                      ],
                                    ),
                                  ),
                                  state.detail['amount']
                                              ['point_exchange_amount'] >
                                          0
                                      ? Padding(
                                          padding: const EdgeInsets.only(
                                              left: 10, top: 5, right: 10),
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text('积分换购抵扣',
                                                  style: TextStyle(
                                                      color: Colors.grey)),
                                              Text(
                                                  '-￥${state.detail['amount']['point_exchange_amount']}',
                                                  style: TextStyle(
                                                      color: Colors.grey))
                                            ],
                                          ),
                                        )
                                      : Padding(
                                          padding: const EdgeInsets.only(
                                              left: 10, top: 5, right: 10),
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text('积分抵扣',
                                                  style: TextStyle(
                                                      color: Colors.grey)),
                                              Text(
                                                  '-￥${state.detail['amount']['point_amount']}',
                                                  style: TextStyle(
                                                      color: Colors.grey))
                                            ],
                                          ),
                                        ),
                                  //if (state.detail['amount']['electronic_wallet'] >0)
                                  Padding(
                                    padding: const EdgeInsets.only(
                                        left: 10, top: 5, right: 10),
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text('福利卡',
                                            style:
                                                TextStyle(color: Colors.grey)),
                                        Text(
                                            '-￥${state.detail['amount']['card_amount']}',
                                            style:
                                                TextStyle(color: Colors.grey))
                                      ],
                                    ),
                                  ),
                                  //if (state.detail['amount']['stored_valueCard'] > 0)
                                  //   Padding(
                                  //     padding: const EdgeInsets.only(left: 10, top: 5, right: 10),
                                  //     child: Row(
                                  //       mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                  //       children: [
                                  //         Text('储值余额', style: TextStyle(color: Colors.grey)),
                                  //         Text('-￥${state.detail['amount']['stored_valueCard']}', style: TextStyle(color: Colors.grey))
                                  //       ],
                                  //     ),
                                  //   ),
                                  //if (state.detail['amount']['other_amount'] > 0)
                                  Padding(
                                    padding: const EdgeInsets.only(
                                        left: 10, top: 5, right: 10),
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text('其他优惠',
                                            style:
                                                TextStyle(color: Colors.grey)),
                                        Text(
                                            '-￥${state.detail["so_sign"] == 16 ? state.detail['deposit_amount'] >= 0 ? state.detail['deposit_amount'] : state.detail['deposit_amount'] * -1 : state.detail['amount']['other_amount'] >= 0 ? state.detail['amount']['other_amount'] : state.detail['amount']['other_amount'] * -1}',
                                            style:
                                                TextStyle(color: Colors.grey))
                                      ],
                                    ),
                                  ),
//state.detail["so_sign"] == 16?'decut_amount':'other_amount'
                                  ///按照小程序逻辑修改
                                  /// 付尾款-------------------------
                                  if (state.detail['deposit_amount'] > 0 &&
                                      state.detail['so_sign'] == 16 &&
                                      state.detail['pay_deposit'] == 1)
                                    googsPrice(
                                        '未付订金', state.detail['deposit_amount'],
                                        hidePreSymbol: true),
                                  if (state.detail['deposit_amount'] > 0 &&
                                      state.detail['so_sign'] == 16 &&
                                      state.detail['pay_deposit'] != 1)
                                    googsPrice(
                                        '已付订金', state.detail['deposit_amount'],
                                        hidePreSymbol: true),
                                  if (state.detail['so_sign'] == 16 &&
                                      state.detail['payment_completed'] == 1)
                                    googsPrice(
                                        '已付尾款', state.detail['balance_payment'],
                                        hidePreSymbol: true),
                                  if (state.detail['so_sign'] == 16 &&
                                      state.detail['payment_completed'] == 0)
                                    googsPrice(
                                        '未付尾款', state.detail['balance_payment'],
                                        hidePreSymbol: true),

                                  /// 超级团-------------------------
                                  if (state.detail['so_sign'] == 19 &&
                                      (state.detail['operate_status_num_id'] ==
                                              90088 ||
                                          state.detail[
                                                  'operate_status_num_id'] ==
                                              90070))
                                    googsPrice(
                                        '已付订金', state.detail['deposit_amount']),
                                  if (state.detail['so_sign'] == 19 &&
                                      state.detail['operate_status_num_id'] ==
                                          90070)
                                    googsPrice('已付差价',
                                        state.detail['balance_pay_amount']),
                                  if (state.detail['so_sign'] == 19 &&
                                      state.detail['operate_status_num_id'] ==
                                          90088 &&
                                      state.detail['need_pay_amount'] != null &&
                                      state.detail['need_pay_amount'] > 0)
                                    googsPrice('未付差价',
                                        state.detail['need_pay_amount']),

                                  /// 定金预售-------------------------
                                  if (state.detail['so_sign'] == 40 &&
                                      (state.detail['operate_status_num_id'] ==
                                              90065 ||
                                          state.detail[
                                                  'operate_status_num_id'] ==
                                              90070))
                                    googsPrice(
                                        '已付订金', state.detail['deposit_amount']),
                                  if (state.detail['so_sign'] == 40 &&
                                      state.detail['operate_status_num_id'] ==
                                          90070)
                                    googsPrice('已付尾款',
                                        state.detail['balance_pay_amount']),
                                  if (state.detail['so_sign'] == 19 &&
                                      state.detail['operate_status_num_id'] ==
                                          90065 &&
                                      state.detail['need_pay_amount'] > 0)
                                    googsPrice('未付尾款',
                                        state.detail['need_pay_amount']),

                                  if (!state.switchValue)
                                    Padding(
                                      padding: const EdgeInsets.only(
                                          left: 10, top: 5, right: 10),
                                      child: Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          Text('配送运费',
                                              style: TextStyle(
                                                  color: Colors.grey)),
                                          Text(
                                              '￥${state.detail['amount']['ef_amount']}',
                                              style:
                                                  TextStyle(color: Colors.grey))
                                        ],
                                      ),
                                    ),
                                  //if (state.detail['amount']['need_pay_amount'] > 0)
                                  Padding(
                                    padding: const EdgeInsets.only(
                                        left: 10, top: 5, right: 10),
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text(
                                            state.detail['order_state'] == 1
                                                ? '应付金额'
                                                : '实付金额',
                                            style:
                                                TextStyle(color: Colors.grey)),
                                        Text(
                                            '￥${state.detail['order_state'] == 1 ? state.detail['amount']['need_pay_amount'].toStringAsFixed(2) : state.detail['amount']['real_pay_amount'].toStringAsFixed(2)}',
                                            style:
                                                TextStyle(color: Colors.grey))
                                      ],
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            Container(
                              height: 24.w,
                              color: Color(0xffF5F5F5),
                            ),
                            Container(
                              color: Color(0xffFFFFFF),
                              padding: EdgeInsets.symmetric(
                                  horizontal: 20.w, vertical: 30.w),
                              child: Column(children: [
                                // Row(
                                //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                //   children: [
                                //     Text("订单总价：", style: TextStyle(fontSize: 26.sp, color: Color(0xff666666))),
                                //     Text("￥${state.detail['total_amount']}", style: TextStyle(fontSize: 28.sp, color: Color(0xff222222))),
                                //   ],
                                // ),
                                // SizedBox(
                                //   height: 20.w,
                                // ),
                                state.detail['operate_status_name'] != '交易失败'
                                    ? Row(
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        children: [
                                          //Text("可赚金额：", style: TextStyle(fontSize: 28.sp, color: Color(0xff222222))),
                                          //Text("￥${state.detail['commission_amount']}", style: TextStyle(fontSize: 28.sp, color: Config.mainColor)),
                                        ],
                                      )
                                    : Container(),
                              ]),
                            ),
                            Container(
                              height: 20.w,
                              color: Color(0xffF5F5F5),
                            ),
                            // Container(
                            //   child: Column(
                            //     children: [
                            //       Padding(
                            //         padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //         child: Row(
                            //           mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //           children: [
                            //             Text('商品金额', style: TextStyle(color: Colors.grey)),
                            //             Text('￥${state.detail['amount']['goods_amount']}',style: TextStyle(color: Colors.grey),)
                            //           ],
                            //         ),
                            //       ),
                            //       if(state.detail['amount']['card_point'] > 0)
                            //       Padding(
                            //         padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //         child: Row(
                            //           mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //           children: [
                            //             Text('优惠券抵扣', style: TextStyle(color: Colors.grey)),
                            //             Text('-￥${state.detail['amount']['card_point']}', style: TextStyle(color: Colors.grey))
                            //           ],
                            //         ),
                            //       ),
                            //       if(state.detail['amount']['point_amount'] > 0)
                            //       Padding(
                            //         padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //         child: Row(
                            //           mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //           children: [
                            //             Text('积分抵扣', style: TextStyle(color: Colors.grey)),
                            //             Text('-￥${state.detail['amount']['point_amount']}', style: TextStyle(color: Colors.grey))
                            //           ],
                            //         ),
                            //       ),
                            //       if(state.detail['amount']['electronic_wallet'] > 0)
                            //         Padding(
                            //           padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //           child: Row(
                            //             mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //             children: [
                            //               Text('礼品卡', style: TextStyle(color: Colors.grey)),
                            //               Text('-￥${state.detail['amount']['electronic_wallet']}', style: TextStyle(color: Colors.grey))
                            //             ],
                            //           ),
                            //         ),
                            //       if(state.detail['amount']['stored_valueCard'] > 0)
                            //         Padding(
                            //           padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //           child: Row(
                            //             mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //             children: [
                            //               Text('储值余额', style: TextStyle(color: Colors.grey)),
                            //               Text('-￥${state.detail['amount']['stored_valueCard']}', style: TextStyle(color: Colors.grey))
                            //             ],
                            //           ),
                            //         ),
                            //       if(state.detail['amount']['other_amount'] > 0)
                            //         Padding(
                            //           padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //           child: Row(
                            //             mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //             children: [
                            //               Text('其他优惠', style: TextStyle(color: Colors.grey)),
                            //               Text('-￥${state.detail['amount']['other_amount']}', style: TextStyle(color: Colors.grey))
                            //             ],
                            //           ),
                            //         ),
                            //       if(state.detail['amount']['ef_amount'] > 0)
                            //         Padding(
                            //           padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //           child: Row(
                            //             mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //             children: [
                            //               Text('配送运费', style: TextStyle(color: Colors.grey)),
                            //               Text('-￥${state.detail['amount']['ef_amount']}', style: TextStyle(color: Colors.grey))
                            //             ],
                            //           ),
                            //         ),
                            //       if(state.detail['amount']['need_pay_amount'] > 0)
                            //         Padding(
                            //           padding: const EdgeInsets.only(left: 10,top: 5,right:10),
                            //           child: Row(
                            //             mainAxisAlignment:MainAxisAlignment.spaceBetween,
                            //             children: [
                            //               Text('实付金额', style: TextStyle(color: Colors.grey)),
                            //               Text('-￥${state.detail['amount']['need_pay_amount']}', style: TextStyle(color: Colors.grey))
                            //             ],
                            //           ),
                            //         ),
                            //     ],
                            //   ),
                            // )
                          ],
                        )
                      ]),
                    ),
                    Container(
                      decoration: new BoxDecoration(
                        color: Colors.white,
                      ),
                      width: 750.w,
                      height: 100.w,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          if (state.detail['is_service_order'] != 1 &&
                              ((state.detail['order_state'] != 1 &&
                                      state.detail['order_status'] != 9 &&
                                      state.detail['so_sign'] != 19) ||
                                  (state.detail['so_sign'] == 19 &&
                                      state.detail['operate_status_num_id'] ==
                                          90070)))
                            GestureDetector(
                              onTap: () {
                                Get.toNamed(RouteConfig.logistics, parameters: {
                                  'tmlId': state.detail["tml_num_id"],
                                  'transCode': state
                                      .detail["ship_tran_no_by_tml_num_ids"]
                                });
                              },
                              child: Container(
                                decoration: new BoxDecoration(
                                    border: new Border.all(
                                        color: Colors.grey, width: 0.3),
                                    borderRadius:
                                        new BorderRadius.circular((20.0))),
                                child: Text('查看物流',
                                    style: TextStyle(
                                        color: Colors.grey, fontSize: 10)),
                                padding: EdgeInsets.only(
                                    top: 4, bottom: 4, left: 8, right: 8),
                                margin: EdgeInsets.only(right: 18),
                              ),
                            ),

                          if (state.detail["comment_type"] == 0)
                            Row(children: [
                              EsOutLineButton(
                                '评价晒单',
                                bgColor: EsColors.Primary,
                                textColor: EsColors.White,
                                onTap: () {
                                  //评价晒单 跳转
                                  // print('  评价参数   widget.data = ${widget.data} ');
                                  var params = {
                                    'use_platform': 2,
                                    'access_token': SpUtil.getString('token'),
                                    'usr_num_id': SpUtil.getInt('empeNumId'),
                                  };

                                  Api.viewEvaluationPermission(params).listen(
                                      (event) {
                                    if (event['code'] == 0) {
                                      String blackType =
                                          event['black_type'].toString();
                                      if (!blackType.contains('2')) {
                                        // print(">>>>>>${state.detail}");
                                        // return;
                                        Get.toNamed(
                                          RouteConfig.pingJiaShaiDan,
                                          arguments: state.detail,
                                        );
                                        return;
                                      }
                                    } else {
                                      toast('评价权限暂时关闭，请联系客服');
                                    }
                                  }, onError: (error) {});
                                  print('晒单评价');
                                },
                              ),
                              SizedBox(width: 12.w),
                            ]),

                          if (state.detail["comment_type"] == 2)
                            Row(children: [
                              EsOutLineButton(
                                '查看评价',
                                bgColor: EsColors.Primary,
                                textColor: EsColors.White,
                                onTap: () {
                                  //评价晒单 跳转
                                  // print('  评价参数   widget.data = ${widget.data} ');
                                  var params = {
                                    'use_platform': 2,
                                    'access_token': SpUtil.getString('token'),
                                    'usr_num_id': SpUtil.getInt('empeNumId'),
                                  };

                                  Api.viewEvaluationPermission(params).listen(
                                      (event) {
                                    if (event['code'] == 0) {
                                      String blackType =
                                          event['black_type'].toString();
                                      if (!blackType.contains('2')) {
                                        Get.toNamed(
                                          RouteConfig.viewComments,
                                          arguments: state.detail,
                                        );
                                        return;
                                      }
                                    }
                                    toast('评价权限暂时关闭，请联系客服');
                                  }, onError: (error) {});
                                  print('晒单评价');
                                },
                              ),
                              SizedBox(width: 12.w),
                            ]),
                          // if (state.detail['order_state'] == 2 ||
                          //     state.detail['order_state'] == 8 ||
                          //     // state.detail['order_state'] == 9 ||
                          //     state.detail['order_state'] == 17 ||
                          //     state.detail['order_state'] == 20)
                          //   GestureDetector(
                          //     onTap: () {
                          //       print('=====ship_tran_no_by_tml_num_ids=====>${state.detail["ship_tran_no_by_tml_num_ids"]}');
                          //       Get.toNamed(RouteConfig.drawBillPage, arguments: {'tml_num_id': state.detail['tml_num_id']});
                          //     },
                          //     child: Container(
                          //       decoration: new BoxDecoration(border: new Border.all(color: Colors.grey, width: 0.3), borderRadius: new BorderRadius.circular((20.0))),
                          //       child: Text('补开发票', style: TextStyle(color: Colors.grey, fontSize: 10)),
                          //       padding: EdgeInsets.only(top: 4, bottom: 4, left: 8, right: 8),
                          //       margin: EdgeInsets.only(right: 18),
                          //     ),
                          //   ),
                          if (state.detail['is_service_order'] != 1 &&
                              (state.detail['order_status'] == 27 ||
                                  state.detail['order_status'] == 28 ||
                                  state.detail['operate_status_num_id'] ==
                                      90130 ||
                                  state.detail['operate_status_num_id'] ==
                                      90125) &&
                              state.detail['tran_type_num_id'] == 3 &&
                              state.detail['all_remain'] > 0.0 &&
                              state.detail['user_num_id'].toString() ==
                                  SpUtil.getInt('empeNumId').toString())
                            GestureDetector(
                              onTap: () {
                                logic.confirmRec(state.detail);
                              },
                              child: Container(
                                decoration: new BoxDecoration(
                                  border: Border(
                                      top: BorderSide(
                                          width: 0.5, color: Colors.grey)),
                                  color: Colors.red,
                                ),
                                height: 150.w,
                                width: 300.w,
                                child: Center(
                                    child: Text(
                                  '确认收货',
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                      fontSize: 36.sp, color: Colors.white),
                                )),
                              ),
                            ),
                          if (state.detail['is_service_order'] != 1 &&
                              (state.detail['order_state'] == 8 ||
                                  state.detail['order_state'] == 9 ||
                                  state.detail['order_state'] == 17 ||
                                  state.detail['order_state'] == 20) &&
                              state.detail['user_num_id'].toString() ==
                                  SpUtil.getInt('empeNumId').toString())
                            GestureDetector(
                              onTap: () {
                                // logic.confirmRec(state.detail);
                                print('====================>');
                                state.detail['distribution_order_item']
                                    .forEach((element) {
                                  logic.buyAgain(element);
                                });
                              },
                              child: Container(
                                decoration: new BoxDecoration(
                                  border: Border(
                                      top: BorderSide(
                                          width: 0.5, color: Colors.grey)),
                                  color: Colors.red,
                                ),
                                height: 150.w,
                                width: 350.w,
                                child: Center(
                                    child: Text(
                                  '加入购物车',
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                      fontSize: 36.sp, color: Colors.white),
                                )),
                              ),
                            ),
                          // SizedBox(
                          //   width: 36.w,
                          // ),
                          state.detail['operate_status_name'] == '待付款' &&
                                  state.ordertype == 1
                              ? Padding(
                                  padding: const EdgeInsets.only(right: 10),
                                  child: GestureDetector(
                                    onTap: () {
                                      logic.closeOrder(context);
                                    },
                                    child: Container(
                                      height: 60.w,
                                      decoration: BoxDecoration(
                                        borderRadius: BorderRadius.all(
                                          Radius.circular(80),
                                        ),
                                        border: Border.all(
                                          color: Color(0xffCCCCCC),
                                        ),
                                      ),
                                      padding: EdgeInsets.symmetric(
                                          horizontal: 25.w),
                                      child: Center(
                                        child: Text(
                                          "取消订单",
                                          style: TextStyle(
                                            fontSize: 28.w,
                                            color: Color(0xff222222),
                                          ),
                                        ),
                                      ),
                                    ),
                                  ),
                                )
                              : Container(),
                          // SizedBox(
                          //   width: 20.w,
                          // ),
                          state.detail['operate_status_name'] == '待付款' &&
                                  state.ordertype == 1
                              ? GestureDetector(
                                  onTap: () {
                                    SpUtil.putString('pay_type', 'xiangqing');
                                    final logic = Get.put(OrderDetialLogic());
                                    final state =
                                        Get.find<OrderDetialLogic>().state;
                                    // 弹窗-去付款
                                    // 如果订单中有购物卡，则直接调用微信支付
                                    // 如果没有购物卡，则弹窗选择购物卡s
                                    //
                                    //
                                    // print(state.detail);
                                    // print('=================>');
                                    logic.state.total['all_payment'] =
                                        state.detail['total_amount'];
                                    // print(logic.state.total['all_payment']);
                                    // // return;
                                    // print(
                                    //     'card_type:${state.detail['card_type']}');
                                    // print(
                                    //     'state.GiftcardList.length:${state.GiftcardList.length}');
                                    if (state.detail['card_type'] == 1 ||
                                        state.GiftcardList.length == 0 ||
                                        state.detail['ec_shop_num_id'] !=
                                            SpUtil.getInt('storeShopNum')) {
                                      //直接调起微信支付
                                      logic.goToMoney(
                                          state.detail['tml_num_id']);
                                      return;
                                    }
                                    //如果是 0， 需要查询福利卡，减去福利卡金额  （total_amount）- 福利卡金额
                                    if (state.detail['card_type'] == 0) {
                                      setState(() {
                                        logic.state.GiftcardList
                                            .forEach((element) {
                                          element['click'] = false;
                                        });
                                        logic.state.isGiftNum = 0;
                                      });
                                      logic.state.isGiftMoney = state
                                          .detail['amount']['need_pay_amount'];
                                      logic.state.realMoney = state
                                          .detail['amount']['need_pay_amount'];

                                      payBottomSheet.showPay(context, state,
                                          logic.goToMoney, logic.setGift,
                                          // tmlnumid: widget.info['tml_num_id']);
                                          tmlnumid: state.detail['tml_num_id']);
                                      // 福利卡可多选
                                      // 如果
                                      // showModalBottomSheet(
                                      //     context: context,
                                      //     // isDismissible: true,
                                      //     isScrollControlled: true,
                                      //     shape: RoundedRectangleBorder(
                                      //         borderRadius: BorderRadius.only(
                                      //             topLeft: Radius.circular(15),
                                      //             topRight:
                                      //                 Radius.circular(15))),
                                      //     builder: (BuildContext context) {
                                      //       return StatefulBuilder(
                                      //           builder: (context1, state1) {
                                      //         return AnimatedPadding(
                                      //             //showModalBottomSheet 键盘弹出时自适应
                                      //             padding:
                                      //                 MediaQuery.of(context)
                                      //                     .viewInsets,
                                      //             duration: const Duration(
                                      //                 milliseconds: 100),
                                      //             child: Container(
                                      //                 constraints:
                                      //                     BoxConstraints(
                                      //                   minHeight: 90,
                                      //                   maxHeight:
                                      //                       MediaQuery.of(
                                      //                                   context)
                                      //                               .size
                                      //                               .height /
                                      //                           1.2,
                                      //                 ),
                                      //                 child: Visibility(
                                      //                   visible: state.detail[
                                      //                               'card_type'] ==
                                      //                           1
                                      //                       ? false
                                      //                       : true,
                                      //                   child: ListView(
                                      //                       shrinkWrap: true,
                                      //                       children: [
                                      //                         Container(
                                      //                             alignment:
                                      //                                 Alignment
                                      //                                     .bottomCenter,
                                      //                             padding:
                                      //                                 EdgeInsets
                                      //                                     .only(
                                      //                                         top: 12),
                                      //                             child: Row(
                                      //                               children: [
                                      //                                 SizedBox(
                                      //                                     width:
                                      //                                         36),
                                      //                                 Expanded(
                                      //                                   child: Text(
                                      //                                       '选择支付方式',
                                      //                                       style: TextStyle(
                                      //                                           fontSize: 32.sp,
                                      //                                           color: Color(0xff666666),
                                      //                                           fontWeight: FontWeight.normal),
                                      //                                       textAlign: TextAlign.center),
                                      //                                 ),
                                      //                                 EsIconButton(
                                      //                                   Icon(
                                      //                                     Icons
                                      //                                         .close,
                                      //                                     size:
                                      //                                         24,
                                      //                                     color:
                                      //                                         Color(0xffcccccc),
                                      //                                   ),
                                      //                                   padding:
                                      //                                       EdgeInsets.only(right: 12),
                                      //                                   onTap:
                                      //                                       () {
                                      //                                     Navigator.of(context)
                                      //                                         .pop();
                                      //                                   },
                                      //                                 )
                                      //                               ],
                                      //                             )),
                                      //                         Padding(
                                      //                           padding: const EdgeInsets
                                      //                                   .symmetric(
                                      //                               horizontal:
                                      //                                   12,
                                      //                               vertical:
                                      //                                   20),
                                      //                           child: Row(
                                      //                             children: [
                                      //                               // Image.asset(
                                      //                               //     'assets/images/selectIcon1.png',
                                      //                               //     width: 16,
                                      //                               //     height: 16),
                                      //                               SizedBox(
                                      //                                 width: 8,
                                      //                               ),
                                      //                               Text(
                                      //                                 '福利卡（已选${logic.state.isGiftNum}张，共${logic.state.GiftcardList.length ?? 0}张）',
                                      //                                 style: TextStyle(
                                      //                                     color: Color(
                                      //                                         0xff333333),
                                      //                                     fontSize: 32
                                      //                                         .sp,
                                      //                                     fontWeight:
                                      //                                         FontWeight.normal),
                                      //                               ),
                                      //                               // Expanded(
                                      //                               //     child: Text(
                                      //                               //   '￥100.00',
                                      //                               //   maxLines: 1,
                                      //                               //   overflow:
                                      //                               //       TextOverflow
                                      //                               //           .ellipsis,
                                      //                               //   textAlign:
                                      //                               //       TextAlign
                                      //                               //           .end,
                                      //                               //   style: TextStyle(
                                      //                               //       color: EsColors
                                      //                               //           .TitleSecondary,
                                      //                               //       fontSize:
                                      //                               //           EsSizes
                                      //                               //               .MD,
                                      //                               //       fontWeight:
                                      //                               //           EsFontWeights
                                      //                               //               .Medium),
                                      //                               // ))
                                      //                             ],
                                      //                           ),
                                      //                         ),
                                      //                         Container(
                                      //                           margin: EdgeInsets
                                      //                               .only(
                                      //                                   left:
                                      //                                       36,
                                      //                                   bottom:
                                      //                                       18),
                                      //                           height: 155,
                                      //                           child: ListView
                                      //                               .builder(
                                      //                                   itemCount: state
                                      //                                       .GiftcardList
                                      //                                       .length,
                                      //                                   scrollDirection:
                                      //                                       Axis
                                      //                                           .horizontal,
                                      //                                   shrinkWrap:
                                      //                                       true,
                                      //                                   itemBuilder:
                                      //                                       (context,
                                      //                                           index) {
                                      //                                     return GestureDetector(
                                      //                                       onTap:
                                      //                                           () {
                                      //                                         state1(() {
                                      //                                           logic.setGift(index); // 修改点击状态
                                      //                                         });
                                      //
                                      //                                         print('选择礼品卡');
                                      //                                       },
                                      //                                       child:
                                      //                                           Stack(children: [
                                      //                                         Container(
                                      //                                           width: 190,
                                      //                                           padding: EdgeInsets.all(6),
                                      //                                           margin: EdgeInsets.only(right: 10),
                                      //                                           child: Column(
                                      //                                             crossAxisAlignment: CrossAxisAlignment.start,
                                      //                                             mainAxisAlignment: MainAxisAlignment.start,
                                      //                                             children: [
                                      //                                               Image.asset('assets/images/welfare_card_cover.jpeg', width: 176, height: 100),
                                      //                                               // CachedImage(
                                      //                                               //     width: 176,
                                      //                                               //     height: 100,
                                      //                                               //     padding: EdgeInsets.zero,
                                      //                                               //     scale: BoxFit.fitWidth,
                                      //                                               //     path:
                                      //                                               //         'assets/images/welfare_card_cover'),
                                      //                                               Expanded(child: SizedBox(height: 2)),
                                      //                                               Text(
                                      //                                                 '福利卡',
                                      //                                                 style: TextStyle(color: EsColors.TitleSecondary, fontSize: EsSizes.XS, fontWeight: EsFontWeights.Normal),
                                      //                                               ),
                                      //                                               Row(
                                      //                                                 children: [
                                      //                                                   Expanded(
                                      //                                                     child: Text(
                                      //                                                       '￥${state.GiftcardList[index]['money_available']}',
                                      //                                                       maxLines: 1,
                                      //                                                       overflow: TextOverflow.ellipsis,
                                      //                                                       style: TextStyle(color: EsColors.TitleSecondary, fontSize: EsSizes.XS, fontWeight: EsFontWeights.Medium),
                                      //                                                     ),
                                      //                                                   ),
                                      //                                                   // Text(
                                      //                                                   //   '有效期至:${ state.GiftcardList[index]['expire_dtme'].toString()}',
                                      //                                                   //   style: TextStyle(
                                      //                                                   //       color: EsColors.Fill,
                                      //                                                   //       fontSize: EsSizes.XXS,
                                      //                                                   //       fontWeight:
                                      //                                                   //           EsFontWeights.Normal),
                                      //                                                   // )
                                      //                                                 ],
                                      //                                               )
                                      //                                             ],
                                      //                                           ),
                                      //                                           decoration: BoxDecoration(
                                      //                                               color: EsColors.White,
                                      //                                               border: Border.all(
                                      //                                                 color: EsColors.Primary,
                                      //                                                 width: 1,
                                      //                                               ),
                                      //                                               borderRadius: BorderRadius.circular(3)),
                                      //                                         ),
                                      //                                         if (state.GiftcardList[index]['click'])
                                      //                                           Positioned(left: 0, top: 0, child: Image.asset('assets/images/selected_left.png', width: 47, height: 47))
                                      //                                       ]),
                                      //                                     );
                                      //                                   }),
                                      //                         ),
                                      //                         YpLine(),
                                      //                         GestureDetector(
                                      //                           behavior:
                                      //                               HitTestBehavior
                                      //                                   .opaque,
                                      //                           onTap: () {
                                      //                             state1(() {
                                      //                               // index = 0;
                                      //                               print(
                                      //                                   '切换支付方式微信');
                                      //                             });
                                      //                           },
                                      //                           child: Padding(
                                      //                             padding: const EdgeInsets
                                      //                                     .symmetric(
                                      //                                 horizontal:
                                      //                                     12,
                                      //                                 vertical:
                                      //                                     20),
                                      //                             child: Row(
                                      //                               children: [
                                      //                                 Image.asset(
                                      //                                     'assets/images/selectIcon1.png',
                                      //                                     width:
                                      //                                         16,
                                      //                                     height:
                                      //                                         16),
                                      //                                 SizedBox(
                                      //                                   width:
                                      //                                       8,
                                      //                                 ),
                                      //                                 Text(
                                      //                                   '微信支付',
                                      //                                   style: TextStyle(
                                      //                                       color:
                                      //                                           EsColors.TitleSecondary,
                                      //                                       fontSize: EsSizes.MD,
                                      //                                       fontWeight: EsFontWeights.Normal),
                                      //                                 ),
                                      //                                 Expanded(
                                      //                                     child:
                                      //                                         Text(
                                      //                                   '￥${logic.state.isGiftMoney}',
                                      //                                   maxLines:
                                      //                                       1,
                                      //                                   overflow:
                                      //                                       TextOverflow.ellipsis,
                                      //                                   textAlign:
                                      //                                       TextAlign.end,
                                      //                                   style: TextStyle(
                                      //                                       color:
                                      //                                           EsColors.TitleSecondary,
                                      //                                       fontSize: EsSizes.MD,
                                      //                                       fontWeight: EsFontWeights.Medium),
                                      //                                 ))
                                      //                               ],
                                      //                             ),
                                      //                           ),
                                      //                         ),
                                      //                         YpLine(),
                                      //                         GestureDetector(
                                      //                           behavior:
                                      //                               HitTestBehavior
                                      //                                   .opaque,
                                      //                           onTap: () {
                                      //                             state1(() {
                                      //                               // index = 1;
                                      //                               print(
                                      //                                   '切换支付方式支付宝');
                                      //                             });
                                      //                           },
                                      //                           child: Padding(
                                      //                             padding: const EdgeInsets
                                      //                                     .symmetric(
                                      //                                 horizontal:
                                      //                                     12,
                                      //                                 vertical:
                                      //                                     20),
                                      //                           ),
                                      //                         ),
                                      //                         YpLine(),
                                      //                         SizedBox(
                                      //                             height: 27),
                                      //                         // Center(
                                      //                         //   child: RichText(
                                      //                         //     text: TextSpan(
                                      //                         //       children: [
                                      //                         //         TextSpan(
                                      //                         //           text: '应付：',
                                      //                         //           style: TextStyle(
                                      //                         //               color: EsColors.Primary,
                                      //                         //               fontSize: EsSizes.XS,
                                      //                         //               fontWeight: EsFontWeights.Normal),
                                      //                         //         ),
                                      //                         //         TextSpan(
                                      //                         //           text: '￥422.08',
                                      //                         //           style: TextStyle(
                                      //                         //               color: EsColors.Primary,
                                      //                         //               fontSize: EsSizes.LG,
                                      //                         //               fontWeight: EsFontWeights.Medium),
                                      //                         //         )
                                      //                         //       ],
                                      //                         //     ),
                                      //                         //   ),
                                      //                         // ),
                                      //                         SizedBox(
                                      //                             height: 16),
                                      //                         EsBottomWidget(
                                      //                             leftTitle:
                                      //                                 null,
                                      //                             rightTitle:
                                      //                                 '确认付款',
                                      //                             rightlick:
                                      //                                 () {
                                      //                               //gyq
                                      //                               print(
                                      //                                   '确认付款');
                                      //                               var amt = logic
                                      //                                   .calculateCardAmount();
                                      //                               print(amt);
                                      //                               SpUtil.putDouble(
                                      //                                   'real_pay_amount',
                                      //                                   state.detail[
                                      //                                       'real_pay_amount']);
                                      //                               SpUtil.putString(
                                      //                                   'tml_num_id',
                                      //                                   state.detail[
                                      //                                       'tml_num_id']);
                                      //                               if (state.detail[
                                      //                                       'total_amount'] ==
                                      //                                   amt) {
                                      //                                 // 1. 卡金额等于订单金额
                                      //                                 var realAmt =
                                      //                                     0.0;
                                      //                                 logic.goToMoney(
                                      //                                     state.detail[
                                      //                                         'tml_num_id'],
                                      //                                     realAmt); //real_pay_amount = 0
                                      //                                 Navigator.of(
                                      //                                         context)
                                      //                                     .pop();
                                      //                               } else if (amt <
                                      //                                   state.detail[
                                      //                                       'total_amount']) {
                                      //                                 // 2. 卡金额小于订单金额
                                      //                                 var realAmt =
                                      //                                     state.detail['total_amount'] -
                                      //                                         amt;
                                      //                                 logic.goToMoney(
                                      //                                     state.detail[
                                      //                                         'tml_num_id'],
                                      //                                     realAmt);
                                      //                                 Navigator.of(
                                      //                                         context)
                                      //                                     .pop();
                                      //                                 //logic.toPay(realAmt);
                                      //                               } else {
                                      //                                 // 如果卡金额大于订单金额，直接去支付
                                      //                                 var realAmt =
                                      //                                     state.detail[
                                      //                                         'total_amount'];
                                      //                                 logic.goToMoney(
                                      //                                     state.detail[
                                      //                                         'tml_num_id'],
                                      //                                     realAmt);
                                      //                                 // logic.toPay(realAmt)
                                      //
                                      //                               }
                                      //                             },
                                      //                             decoration:
                                      //                                 null)
                                      //                       ]),
                                      //                 )));
                                      //       });
                                      //     });
                                    }
                                  },
                                  child: Container(
                                    height: 60.w,
                                    margin: EdgeInsets.only(right: 20.w),
                                    padding:
                                        EdgeInsets.symmetric(horizontal: 20.w),
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.all(
                                        Radius.circular(80),
                                      ),
                                      color: Config.mainColor,
                                    ),
                                    child: Center(
                                      child: Row(
                                        children: [
                                          Text(
                                              "去付款￥${state.detail['order_state'] == 1 ? state.detail['amount']['need_pay_amount'] : state.detail['amount']['real_pay_amount']}",
                                              style: TextStyle(
                                                  fontSize: 28.w,
                                                  color: Colors.white)),
                                          Padding(
                                            padding:
                                                const EdgeInsets.only(left: 10),
                                            child: Text("${state.timerValue}",
                                                style: TextStyle(
                                                    fontSize: 28.w,
                                                    color: Colors.white)),
                                          )
                                        ],
                                      ),
                                      // child: Text(
                                      //   "去付款￥${state.detail['real_pay_amount']}${state.timerValue}",
                                      //   style: TextStyle(
                                      //     fontSize: 28.w,
                                      //     color: Colors.white,
                                      //   ),
                                      // ),
                                    ),
                                  ),
                                )
                              : Container(),

                          /// 超级团补差价
                          Visibility(
                            visible: rules('a23', state.detail),
                            child: Padding(
                              padding: const EdgeInsets.only(right: 6),
                              child: soSignPayBtn(
                                onTap: () {
                                  final logic = Get.put(OrderDetialLogic());
                                  final state =
                                      Get.find<OrderDetialLogic>().state;
                                  if (state.detail['need_pay_amount'] != null) {
                                    logic.state.total['all_payment'] =
                                        state.detail['need_pay_amount'];
                                  } else {
                                    logic.state.total['all_payment'] = state
                                        .detail['amount']['need_pay_amount'];
                                    logic.state.detail['need_pay_amount'] =
                                        state.detail['amount']
                                            ['need_pay_amount'];
                                  }
                                  SpUtil.putString('order_num_id',
                                      state.detail['tml_num_id']);
                                  SpUtil.putDouble('need_pay_amount',
                                      state.detail['need_pay_amount']);
                                  if (state.detail['card_type'] == 1 ||
                                      state.GiftcardList.length == 0 ||
                                      state.detail['ec_shop_num_id'] !=
                                          SpUtil.getInt('storeShopNum')) {
                                    //直接调起微信支付
                                    logic.goToMoney(state.detail['tml_num_id']);
                                    return;
                                  }
                                  //如果是 0， 需要查询福利卡，减去福利卡金额  （total_amount）- 福利卡金额
                                  if (state.detail['card_type'] == 0) {
                                    // 福利卡可多选
                                    // 如果
                                    payBottomSheet.showPay(context, logic.state,
                                        logic.goToMoney, logic.setGift,
                                        tmlnumid: state.detail['tml_num_id']);
                                  }
                                },
                                text: '补差价',
                                fontSize: 12,
                                showTimerValue: false,
                              ),
                            ),
                          ),

                          /// 退团
                          Visibility(
                              visible: rules('a22', state.detail),
                              child: Padding(
                                padding: const EdgeInsets.only(right: 6),
                                child: soSignPayBtn(
                                  onTap: () {
                                    showDialog(
                                      context: context,
                                      builder: (BuildContext context) {
                                        return CupertinoAlertDialog(
                                          title: Text("提示"),
                                          content: Column(
                                            children: <Widget>[
                                              SizedBox(
                                                height: 10,
                                              ),
                                              Align(
                                                child: Text("确定要取消吗?"),
                                                alignment: Alignment(0, 0),
                                              ),
                                            ],
                                          ),
                                          actions: <Widget>[
                                            CupertinoDialogAction(
                                              child: Text("否"),
                                              onPressed: () {
                                                Navigator.pop(context);
                                              },
                                            ),
                                            CupertinoDialogAction(
                                              child: Text("是"),
                                              onPressed: () {
                                                logic.refund(
                                                    info: state.detail);
                                              },
                                            ),
                                          ],
                                        );
                                      },
                                    );
                                  },
                                  text: '退团',
                                  fontSize: 12,
                                  showTimerValue: false,
                                ),
                              )),
                          Visibility(
                              visible: rules('a25', state.detail),
                              child: Padding(
                                padding: const EdgeInsets.only(right: 6),
                                child: soSignPayBtn(
                                  onTap: () {
                                    showDialog(
                                      context: context,
                                      builder: (BuildContext context) {
                                        return CupertinoAlertDialog(
                                          title: Text("提示"),
                                          content: Column(
                                            children: <Widget>[
                                              SizedBox(
                                                height: 10,
                                              ),
                                              Align(
                                                child: Text("确定要取消吗?"),
                                                alignment: Alignment(0, 0),
                                              ),
                                            ],
                                          ),
                                          actions: <Widget>[
                                            CupertinoDialogAction(
                                              child: Text("否"),
                                              onPressed: () {
                                                Navigator.pop(context);
                                              },
                                            ),
                                            CupertinoDialogAction(
                                              child: Text("是"),
                                              onPressed: () {
                                                logic.refund(
                                                    info: state.detail);
                                              },
                                            ),
                                          ],
                                        );
                                      },
                                    );
                                  },
                                  text: '退团',
                                  fontSize: 12,
                                  showTimerValue: false,
                                ),
                              )),

                          /// 定金预售付预售尾款
                          Visibility(
                            visible: rules('a21', state.detail),
                            child: Padding(
                              padding: const EdgeInsets.only(right: 6),
                              child: soSignPayBtn(
                                onTap: () {
                                  final logic = Get.put(OrderDetialLogic());
                                  final state =
                                      Get.find<OrderDetialLogic>().state;
                                  Get.toNamed(RouteConfig.endSaleOrder,
                                      arguments: {
                                        'shopnum': 1,
                                        // 'shop_id': state.detail['item_lists'][0]
                                        //     ['ec_shop_num_id'],
                                        // 'tml_num_id':
                                        //     state.detail['tml_num_id'],
                                        'shop_id': state.detailShopId,
                                        'tml_num_id': state.detailOrderNumId,
                                        'isFontSale': false,
                                        'needPopSecond': true
                                      });
                                },
                                text: '付预售尾款',
                                fontSize: 12,
                                showTimerValue: false,
                              ),
                            ),
                          ),

                          /// 定金预售退预售定金
                          Visibility(
                              visible: rules('a20', state.detail),
                              child: Padding(
                                padding: const EdgeInsets.only(right: 6),
                                child: soSignPayBtn(
                                  onTap: () {
                                    showDialog(
                                      context: context,
                                      builder: (BuildContext context) {
                                        return CupertinoAlertDialog(
                                          title: Text("提示"),
                                          content: Column(
                                            children: <Widget>[
                                              SizedBox(
                                                height: 10,
                                              ),
                                              Align(
                                                child: Text("确定要取消吗?"),
                                                alignment: Alignment(0, 0),
                                              ),
                                            ],
                                          ),
                                          actions: <Widget>[
                                            CupertinoDialogAction(
                                              child: Text("否"),
                                              onPressed: () {
                                                Navigator.pop(context);
                                              },
                                            ),
                                            CupertinoDialogAction(
                                              child: Text("是"),
                                              onPressed: () {
                                                logic.refund(
                                                    info: state.detail);
                                              },
                                            ),
                                          ],
                                        );
                                      },
                                    );
                                  },
                                  text: '退预售定金',
                                  fontSize: 12,
                                  showTimerValue: false,
                                ),
                              )),
                        ],
                      ),
                    ),
                  ],
                );
        },
      ),
    );
  }

  /// 配送方式
  _showCupertinoActionSheet(context) async {
    var result = await showCupertinoModalPopup(
        context: context,
        builder: (context) {
          return CupertinoActionSheet(
            title: Text('选择配送方式'),
            actions: <Widget>[
              CupertinoActionSheetAction(
                child: Text('快递'),
                onPressed: () {
                  logic.selectTranType('快递');
                  Navigator.of(context).pop('3');
                },
                isDefaultAction: true,
              ),
              CupertinoActionSheetAction(
                child: Text('自提'),
                onPressed: () {
                  logic.selectTranType('自提');
                  Navigator.of(context).pop('5');
                },
                isDefaultAction: true,
              ),
            ],
            cancelButton: CupertinoActionSheetAction(
              child: Text('取消'),
              onPressed: () {
                Navigator.of(context).pop('cancel');
              },
            ),
          );
        });
    print('$result');
  }

  /// 配送类型
  _showCupertinoActionSheet1(context) async {
    var result = await showCupertinoModalPopup(
        context: context,
        builder: (context) {
          return CupertinoActionSheet(
            title: Text('选择配送类型'),
            actions: <Widget>[
              CupertinoActionSheetAction(
                child: Container(
                  width: 500.w,
                  child: Stack(
                    children: [
                      Center(
                        child: Text('立即发货'),
                      ),
                      logic.state.tml_type == "立即发货"
                          ? Positioned(
                              right: 0.w,
                              child: Icon(
                                Icons.check,
                                color: Colors.blue,
                                size: 48.sp,
                              ),
                            )
                          : Container(),
                    ],
                  ),
                ),
                onPressed: () {
                  logic.selectTmlType('立即发货');
                  Navigator.of(context).pop('0');
                },
                isDefaultAction: true,
              ),
              CupertinoActionSheetAction(
                child: Container(
                  width: 500.w,
                  child: Stack(
                    children: [
                      Center(
                        child: Text('暂不发货'),
                      ),
                      logic.state.tml_type == "暂不发货"
                          ? Positioned(
                              right: 0.w,
                              child: Icon(
                                Icons.check,
                                color: Colors.blue,
                                size: 48.sp,
                              ),
                            )
                          : Container(),
                    ],
                  ),
                ),
                onPressed: () {
                  logic.selectTmlType('暂不发货');
                  Navigator.of(context).pop('2');
                },
                isDefaultAction: true,
              ),
              CupertinoActionSheetAction(
                child: Container(
                  width: 500.w,
                  child: Stack(
                    children: [
                      Center(
                        child: Text('预约发货'),
                      ),
                      logic.state.tml_type == "预约发货"
                          ? Positioned(
                              right: 0.w,
                              child: Icon(
                                Icons.check,
                                color: Colors.blue,
                                size: 48.sp,
                              ),
                            )
                          : Container(),
                    ],
                  ),
                ),
                onPressed: () {
                  logic.selectTmlType('预约发货');

                  Navigator.of(context).pop('1');
                },
                isDefaultAction: true,
              ),
            ],
            cancelButton: CupertinoActionSheetAction(
              child: Text('取消'),
              onPressed: () {
                Navigator.of(context).pop('cancel');
              },
            ),
          );
        });
    print('$result');
  }

  /// 自提点
  _selectProduct(context) {
    //用于在底部打开弹框的效果
    return SimpleDialog(
      title: Text(
        '选择自提点',
        style: TextStyle(
          color: Color(0xff333333),
          fontSize: 26.w,
          fontWeight: FontWeight.w100,
        ),
        textAlign: TextAlign.center,
      ),
      titleTextStyle: TextStyle(
          fontSize: 16, fontWeight: FontWeight.bold, color: Colors.blue),
      children: [
        GetBuilder<OrderDetialLogic>(
          builder: (logic) {
            return Container(
              child: Container(
                padding: EdgeInsets.symmetric(
                  horizontal: 20.w,
                ),
                height: 400.w,
                width: 300.w,
                child: ListView.builder(
                  shrinkWrap: true,
                  primary: false,
                  itemBuilder: (ctx, i) {
                    var item = state.selfHelpAddressList[i];
                    return GestureDetector(
                      onTap: () {
                        logic.selectDian(i, item);
                      },
                      child: Container(
                        padding: EdgeInsets.only(bottom: 15.w),
                        margin: EdgeInsets.only(top: 15.w),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            state.selected == i
                                ? Image(
                                    image: AssetImage(
                                        "assets/images/selectIcon1.png"),
                                    width: 36.w,
                                  )
                                : Image(
                                    image: AssetImage("assets/images/save.png"),
                                    width: 36.w,
                                  ),
                            SizedBox(
                              width: 10.w,
                            ),
                            Expanded(
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text(
                                    item["sub_unit_name"],
                                    style: TextStyle(
                                      color: Color(0xff222222),
                                      fontSize: 28.sp,
                                    ),
                                  ),
                                  Text(
                                    '${item["prv_name"]}${item["city_name"]}${item["city_area_name"]}${item["town_name"] ?? ''}${item["adr"]}',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: 24.sp,
                                    ),
                                    maxLines: 2,
                                    textAlign: TextAlign.start,
                                    overflow: TextOverflow.ellipsis,
                                  ),
                                ],
                              ),
                            ),
                            Container(
                              padding: EdgeInsets.only(top: 10.w, bottom: 10.w),
                              child: Divider(
                                color: Color(0xff000000),
                              ),
                            ),
                          ],
                        ),
                      ),
                    );
                  },
                  itemCount: state.selfHelpAddressList.length,
                ),
              ),
            );
          },
        ),
        SimpleDialogOption(
          onPressed: () {
            logic.submit();
            Navigator.pop(context);
          },
          child: Container(
            color: Colors.white,
            child: Container(
              height: 80.w,
              decoration: BoxDecoration(
                color: Config.mainColor,
                borderRadius: BorderRadius.circular(40.w),
              ),
              child: Center(
                child: Text(
                  "确定",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 28.w,
                  ),
                ),
              ),
            ),
          ),
        ),
      ],
      backgroundColor: Colors.white,
      elevation: 10,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(5),
      ),
    );
  }
}
